/**
 * Copyright (c) 2011 Paul Wagner
 */
package com.pew.tasktimer.domain.report;

import javax.xml.bind.annotation.XmlRootElement;
import org.apache.log4j.*;

import com.pew.tasktimer.domain.Task;
import com.pew.tasktimer.domain.report.ReportSumation.GROUP_BY;

/**
 * @author Elwin
 * Created: Mar 30, 2011
 * Purpose: Root document for reporting.
 *
 */
public class Report {

	static Logger cLogger = Logger.getLogger(Report.class);
	
	public static ReportSumation generateReport(Task myTasks[]) {
		
		cLogger.info("Generating a report.");
		//Set up ReportSumations
		ReportSumation lReportOverall = new ReportSumation();
		ReportSumation lReportMonth = new ReportSumation();
		ReportSumation lReportDay = new ReportSumation();
		ReportSumation lReportProject = new ReportSumation();
		
		//Set their groupings
		lReportOverall.setGrouping(GROUP_BY.NOT_SET);
		lReportMonth.setGrouping(GROUP_BY.MONTH_YEAR);
		lReportDay.setGrouping(GROUP_BY.MONTH_DAY_YEAR);
		lReportProject.setGrouping(GROUP_BY.PROJECT);
		
		//Set how this rolls
		lReportDay.addReportSumation(lReportProject);
		lReportMonth.addReportSumation(lReportDay);
		lReportOverall.addReportSumation(lReportMonth);
		
		if(myTasks != null)
		{
			int liMax = myTasks.length;
			for(int i = 0; i < liMax; i++) {
				lReportOverall.addTask(myTasks[i]);
			}
		} // otherwise return just the Framework.
		
		
		return lReportOverall;
	}
	
	
}
